package com.tongtong.middleware.client;

import java.math.BigInteger;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.web3j.protocol.core.methods.response.EthBlock;

import com.tongtong.middleware.vo.params.AccountParams;
import com.tongtong.middleware.vo.params.MetaDataParams;
import com.tongtong.middleware.vo.params.bsn.RechargeRequest;
import com.tongtong.middleware.vo.params.erc1155.ApprovalParams;
import com.tongtong.middleware.vo.params.erc1155.BurnBatchNFTParams;
import com.tongtong.middleware.vo.params.erc1155.BurnNFTParams;
import com.tongtong.middleware.vo.params.erc1155.MintBatchNFTParams;
import com.tongtong.middleware.vo.params.erc1155.MintNFTParams;
import com.tongtong.middleware.vo.params.erc1155.TransferBatchParams;
import com.tongtong.middleware.vo.params.erc1155.TransferParams;
import com.tongtong.middleware.vo.params.nft.MetaDataByTokenIdParams;
import com.tongtong.middleware.vo.params.nft.Proposal;
import com.tongtong.middleware.vo.response.AccountBalanceRes;
import com.tongtong.middleware.vo.response.AccountResponse;
import com.tongtong.middleware.vo.response.EstimateGasRes;
import com.tongtong.middleware.vo.response.TransactionMergeData;

import xyz.xtt.common.response.ApiResult;

/**
 * @author wangqi
 */
@FeignClient(name = "nft-blockchain", fallbackFactory = BlockchainClientFallbackFactory.class)
public interface BlockchainClient {
	// ============================merge接口开始=========================================
	@GetMapping("/merge/account/balance")
	ApiResult<AccountBalanceRes> mergeAccountBalance();

	// ============================merge接口结束=========================================
	// ============================数字资产接口开始=========================================
	@PostMapping("/eth/nft/metadata")
	ApiResult<String> metadata(@RequestBody MetaDataParams request);

	@PostMapping("/eth/nft/updateMetadataByTokenId")
	ApiResult<String> updateMetadataByTokenId(@RequestBody MetaDataByTokenIdParams request);

	@PostMapping("/eth/nft/mintNFT")
	ApiResult<String> mintNFT(@RequestBody com.tongtong.middleware.vo.params.nft.MintNFTParams request);

	@PostMapping("/eth/nft/mintBatchNFT")
	ApiResult<String> mintBatchNFT(@RequestBody com.tongtong.middleware.vo.params.nft.MintBatchNFTParams request);

	@PostMapping("/eth/nft/transfer")
	ApiResult<String> transfer(@RequestBody com.tongtong.middleware.vo.params.nft.TransferParams request);

	@PostMapping("/eth/nft/transferBatch")
	ApiResult<String> transferBatch(@RequestBody com.tongtong.middleware.vo.params.nft.TransferBatchParams request);

	@PostMapping("/eth/nft/approval")
	ApiResult<String> approval(@RequestBody com.tongtong.middleware.vo.params.nft.ApprovalParams request);

	@PostMapping("/eth/nft/burnNFT")
	ApiResult<String> burnNFT(@RequestBody com.tongtong.middleware.vo.params.nft.BurnNFTParams request);

	@PostMapping("/eth/nft/burnBatchNFT")
	ApiResult<String> burnBatchNFT(@RequestBody com.tongtong.middleware.vo.params.nft.BurnBatchNFTParams request);

	@GetMapping("/eth/nft/tokenURI")
	ApiResult<String> tokenURI(@RequestParam("proposal") Proposal proposal, @RequestParam("tokenId") BigInteger tokenId);

	@GetMapping("/eth/nft/balanceOf")
	ApiResult<String> balanceOf(@RequestParam("proposal") Proposal proposal, @RequestParam("account") String account,
			@RequestParam("tokenId") BigInteger tokenId);

	// ============================数字资产接口结束=========================================
	// ============================BSN接口开始=========================================
	@PostMapping("/bsn/gas/recharge")
	ApiResult<String> recharge(@RequestBody RechargeRequest request);

	@PostMapping("/bsn/gas/balance")
	ApiResult<Double> balance();

	// ============================BSN接口结束=========================================
	// ============================ETH接口开始=========================================
	@PostMapping("/eth/account")
	ApiResult<AccountResponse> createAndQueryAccount(@RequestBody AccountParams request);

	@GetMapping("/eth/getBlockNumber")
	ApiResult<BigInteger> getBlockNumber();

	@GetMapping("/eth/getBlockByNumber")
	ApiResult<EthBlock.Block> getBlockByNumber(@RequestParam("blockNumber") BigInteger blockNumber);

	@GetMapping("/eth/getTransactionInfo")
	ApiResult<TransactionMergeData> getTransactionInfo(@RequestParam("hash") String hash);

	@GetMapping("/eth/getBalance")
	ApiResult<BigInteger> getBalance(@RequestParam("account") String account);

	@GetMapping("/eth/estimateGas")
	ApiResult<EstimateGasRes> estimateGas(@RequestParam("from") String from, @RequestParam("to") String to, @RequestParam("input") String input);

	// ============================ETH接口结束=========================================
	// ============================ERC721接口开始=========================================
	@PostMapping("/eth/erc721/mintNFT")
	ApiResult<String> erc721MintNFT(@RequestBody com.tongtong.middleware.vo.params.erc721.MintNFTParams request);

	@PostMapping("/eth/erc721/approval")
	ApiResult<String> erc721Approval(@RequestBody com.tongtong.middleware.vo.params.erc721.ApprovalParams request);

	@PostMapping("/eth/erc721/transfer")
	ApiResult<String> erc721Transfer(@RequestBody com.tongtong.middleware.vo.params.erc721.TransferParams request);

	@PostMapping("/eth/erc721/burnNFT")
	ApiResult<String> erc721BurnNFT(@RequestBody com.tongtong.middleware.vo.params.erc721.BurnNFTParams request);

	@GetMapping("/eth/erc721/balanceOf")
	ApiResult<String> erc721BalanceOf(@RequestParam("account") String account);

	@GetMapping("/eth/erc721/isApprovedForAll")
	ApiResult<String> erc721IsApprovedForAll(@RequestParam("account") String account, @RequestParam("operator") String operator);

	@GetMapping("/eth/erc721/tokenURI")
	ApiResult<String> erc721TokenURI(@RequestParam("tokenId") BigInteger tokenId);

	@GetMapping("/eth/erc721/ownerOf")
	ApiResult<String> erc721OwnerOf(@RequestParam("tokenId") BigInteger tokenId);

	// ============================ERC721接口结束=========================================
	// ============================ERC1155接口开始=========================================
	@PostMapping("/eth/erc1155/mintNFT")
	ApiResult<String> erc1155MintNFT(@RequestBody MintNFTParams request);

	@PostMapping("/eth/erc1155/mintBatchNFT")
	ApiResult<String> erc1155MintBatchNFT(@RequestBody MintBatchNFTParams request);

	@PostMapping("/eth/erc1155/transfer")
	ApiResult<String> erc1155Transfer(@RequestBody TransferParams request);

	@PostMapping("/eth/erc1155/transferBatch")
	ApiResult<String> erc1155TransferBatch(@RequestBody TransferBatchParams request);

	@PostMapping("/eth/erc1155/approval")
	ApiResult<String> erc1155Approval(@RequestBody ApprovalParams request);

	@PostMapping("/eth/erc1155/burnNFT")
	ApiResult<String> erc1155BurnNFT(@RequestBody BurnNFTParams request);

	@PostMapping("/eth/erc1155/burnBatchNFT")
	ApiResult<String> erc1155BurnBatchNFT(@RequestBody BurnBatchNFTParams request);

	@GetMapping("/eth/erc1155/balanceOf")
	ApiResult<String> erc1155BalanceOf(@RequestParam("account") String account, @RequestParam("tokenId") BigInteger tokenId);

	@GetMapping("/eth/erc1155/isApprovedForAll")
	ApiResult<String> erc1155IsApprovedForAll(@RequestParam("account") String account, @RequestParam("operator") String operator);

	@GetMapping("/eth/erc1155/tokenURI")
	ApiResult<String> erc1155TokenURI(@RequestParam("tokenId") BigInteger tokenId);
	// ============================ERC1155接口结束=========================================

}
